#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
from multiprocessing import Process
from multiprocessing import Queue
import subprocess


def run_pro(name):  # 子进程执行的代码
    print("Run child process %s(%s)" % (name, os.getpid()))


if __name__ == '__main__':
    print("Parent process %s is running!" % os.getpid())
    p = Process(target=run_pro, args=("name",))
    print("Child process will start!")
    p.start()
    p.join()  # 方法可以等待子进程结束后再继续往下运行，通常用于进程间的同步
    print("Child process is end!")
# --------------------------------------子进程------------------------------
print("$ nslookup www.baidu.com")
r = subprocess.call(["nslookup", 'www.baidu.com'])
print('Exit code:', r)
# -----------------------------------进程间通信------------------------------
# 在Linux上进行测试


